<?php
function ListTourType()
{
    global $dbsql,$language;
    
    $sql_select = "select iId,cName,cUrlString,cDescription from tbltourtype 
        where cLanguage='$language' and iStatus=1 order by iOrder";
    return $dbsql->load($sql_select);
}

function getLinkTourRoot($idP)
{
    global $dbsql,$language;
    
    $sql_select = "select cUrlString from tblcategory 
                    where cLanguage ='$language' and cType = 'tour'";
    $rs = $dbsql->query_fetch($sql_select);
    return $rs['cUrlString'];
}
function ListTourByTypeId($typeid,$limit = 2)
{
    global $dbsql,$language;
    $typeid     = intval($typeid);
    $sql_where  = " from tblsettour where (iParentId=$typeid or iParentId2=$typeid) and cLanguage='$language' and iStatus=1";
    
    $sql_select = "select iId,cName,cUrlString,cImage,cDays,cPriceFrom,cHighLights,cMetaDescription ".$sql_where ." order by iOrder limit $limit";
    return $dbsql->load($sql_select);
}

function ListTourByType($typeid)
{
    global $dbsql,$language,$html;
    
    $typeid     = intval($typeid);
    $sql_where  = " from tblsettour where (iParentId=$typeid or iParentId2=$typeid) and cLanguage='$language' and iStatus=1";
    $sql_select = "select count(iId) as count ".$sql_where;
    $result     = $dbsql->query_fetch($sql_select);
    $countall   = $result['count'];
    
    list($lat,$lall)    = Split_Page($countall);
    $sql_select = "select iId,cName,cUrlString,cImage,cDays,cPriceFrom,cHighLights ".$sql_where ." order by iOrder limit $lat,$lall";
    $rs         = $dbsql->query($sql_select);
    $rows       = $dbsql->num_rows($rs);
    $return     = '<div class="ajaxpage">';
    while($result   = $dbsql->fetch_array($rs))
    {
        $link    = GetLinkTourById($result['iId'],$result['cUrlString']);
        $return .= '<a class="listtour" href="'.$link.'" title="'.$result['cName'].'">';
        $return .= '<span class="img"><img src="'.GetIntroImg($result['cImage'],true).'" width="155" alt="'.$result['cName'].'" /></span>';
        $return .= '<span class="tt">'.$result['cName'];
        $return .= '<span class="d">'.$result['cDays'].'<br />'.$result['cPriceFrom'].'</span></span>';
        $return .= '<span class="w">'.$result['cHighLights'].'</span>';
        $return .= '<span class="l"></span>';
        $return .= '<span class="f">'.getLang('Find out more').'</span>';        
        $return .= '</a>';
    }
    if($rows==0)
    {
        $return .= '<div class="notfound">'.getLang('Not found result!').'</div>';
    }
    $return     .= "<div class='clear'>&nbsp;</div></div>";
    return $return;
}
?>